#include "ConfigDialog.h"

#include <QDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>


ConfigDialog::ConfigDialog(QWidget *parent)
    : QDialog(parent) {
    // 创建表单布局
    QFormLayout *formLayout = new QFormLayout;

//        添加输入框
    apiKey1LineEdit = new QLineEdit;
    secretKey1LineEdit = new QLineEdit;
    apiKey2LineEdit = new QLineEdit;
    secretKey2LineEdit = new QLineEdit;

    formLayout->addRow(new QLabel("语音识别模型 API Key:"), apiKey1LineEdit);
    formLayout->addRow(new QLabel("语音识别模型 Secret Key:"), secretKey1LineEdit);
    formLayout->addRow(new QLabel("语音合成模型 API Key:"), apiKey2LineEdit);
    formLayout->addRow(new QLabel("语音合成模型 Secret Key:"), secretKey2LineEdit);

    // 创建按钮
    QPushButton *okButton = new QPushButton("确定", this);
    QPushButton *cancelButton = new QPushButton("取消", this);

    QHBoxLayout *buttonLayout = new QHBoxLayout();
    buttonLayout->addWidget(okButton);
    buttonLayout->addWidget(cancelButton);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(formLayout);
    mainLayout->addLayout(buttonLayout);

    setLayout(mainLayout);

    // 连接信号和槽
    connect(okButton, &QPushButton::clicked, this, &ConfigDialog::accept);
    connect(cancelButton, &QPushButton::clicked, this, &ConfigDialog::reject);
}

QString ConfigDialog::getApiKey1() const { return apiKey1LineEdit->text(); }
QString ConfigDialog::getSecretKey1() const { return secretKey1LineEdit->text(); }
QString ConfigDialog::getApiKey2() const { return apiKey2LineEdit->text(); }
QString ConfigDialog::getSecretKey2() const { return secretKey2LineEdit->text(); }